import json
import sys
from pathlib import Path
from os.path import dirname, abspath
path = dirname(str(Path(__file__).resolve().parents[0]))
if path not in sys.path:
    sys.path.append(path)
import yaml


def __get_config():
    with open("config.yaml", "r") as f:
        config = yaml.load(f, Loader=yaml.FullLoader)
    return config

def get_bapi_config(appId: str):
    """
    {
        "app_id": "rbm",
        "app_secret": "xxx"
    }
    """
    config = __get_config()
    return config["bapi"][appId]

def get_sso_config(env: str = "prod"):
    """
    {
        "username": "xxx",
        "password": "xxx"
    }
    """
    config = __get_config()
    return config["sso"][env]

def get_es_config(appId: str):
    """
    {
        "host": "https://opsadm.xkw.com/rbmes",
        "username": "mp-rbm",
        "password": "xxx"
    }
    """
    config = __get_config()
    return config["es"][appId]

if __name__ == "__main__":
    print(get_es_config("rbm")) 